package com.github.niefy.modules.third.dto;

import cn.hutool.crypto.digest.DigestUtil;
import lombok.Data;

import javax.validation.constraints.NotEmpty;

@Data
public class SpmOut {

    @NotEmpty(message = "apiid不得为空")
    private String apiid;

    @NotEmpty(message = "consid不得为空")
    private String consid;

    /**
     *
     */
    private String customkeyname;

    private final Long timestamp = System.currentTimeMillis()/1000;

    private String sign;

    public void createSign(String apiid, String consid, String customkeyname,
                           String accesskey, String customkey){
        this.apiid = apiid;
        this.consid = consid;
        this.customkeyname = customkeyname;
        sign = DigestUtil.md5Hex(accesskey + timestamp + customkey);
    }
}
